﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FCDB.Entity;
using Wf5.Engine.Business;
using Wf5.Engine.Common;


namespace Wf5.Engine.Core
{
    /// <summary>
    /// 开始节点
    /// </summary>
    internal class StartNode : NodeBase, ICompleteAutomaticlly
    {
        internal StartNode(ActivityEntity activity)
            : base(activity)
        {

        }

        #region ICompleteAutomaticlly 成员

        public GatewayExecutedResult CompleteAutomaticlly(WfProcessInstance processInstance,
            Guid transitionGUID,
            WfActivityInstance fromActivityInstance, 
            ActivityResource activityResource  
             )
        {
            //开始节点没前驱信息
            var toActivityInstance = base.CreateActivityInstanceObject(processInstance, activityResource.LogonUser);

            base.InsertActivityInstance(toActivityInstance 
                 );

            base.CompleteActivityInstance(toActivityInstance.ID,
                activityResource 
                 );

            SyncActivityInstanceObjectState(NodeStateEnum.Completed);

            GatewayExecutedResult result = GatewayExecutedResult.CreateGatewayExecutedResult(GatewayExecutedStatus.Successed);
            return result;
        }

        #endregion
    }
}
